//
//  KLNumberPad.m
//  KLExchangeRate
//
//  Created by apple on 2017/11/28.
//  Copyright © 2017年 bonc. All rights reserved.
//

#import "KLNumberPad.h"

#import "KLNumberPadButton.h"

typedef NS_ENUM(NSInteger,KLNumberPadButtonType){
    KeyboardNumberZero = 0,
    KeyboardNumberOne,
    KeyboardNumberTwo,
    KeyboardNumberThree,
    KeyboardNumberFour,
    KeyboardNumberFive,
    KeyboardNumberSix,
    KeyboardNumberSeven,
    KeyboardNumberEight,
    KeyboardNumberNine,
    KeyboardDecimalPoint = 10,
    KeyboardOperatorAdd = 101,
    KeyboardOperatorSubtract = 102,
    KeyboardOperatorMutiply = 103,
    KeyboardOperatorDivide = 104,
    KeyboardDelete = 105,
};

@interface KLNumberPad ()

@property (weak, nonatomic) IBOutlet KLNumberPadButton *deleteButton;
@end

@implementation KLNumberPad

+ (instancetype)numberPadView {
    KLNumberPad *view = [[[NSBundle mainBundle] loadNibNamed:@"KLNumberPad" owner:nil options:nil] firstObject];
    return view;
}

- (IBAction)KeyboardNumberDidClick:(KLNumberPadButton *)sender {
    if (self.delegate && [self.delegate respondsToSelector:@selector(addInput:)]) {
        [self.delegate addInput:sender.titleLabel.text];
    }
}

- (IBAction)deleteButtonDidLongPress:(UILongPressGestureRecognizer *)sender {
    if (self.delegate && [self.delegate respondsToSelector:@selector(clearInput)]) {
        [self.delegate clearInput];
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
